﻿using IntelligentAgriculture.Contracts.Interface;
using IntelligentAgriculture.Domain.Entity;
using IntelligentAgriculture.WebAPI.Application.Command.GermlineHistoryRecordsCommand;
using MediatR;

namespace IntelligentAgriculture.WebAPI.Application.CommandHandler.GermlineHistoryRecordsCommandHandler
{
    /// <summary>
    /// 种母历史记录添加commandHandler
    /// </summary>
    public class AddHistoryCommandHander : IRequestHandler<AddHistoryCommand, Results<int>>
    {

        private readonly IHistoryRecordService _service;
        public AddHistoryCommandHander(IHistoryRecordService service)
        {
            _service = service;
        }
        public async Task<Results<int>> Handle(AddHistoryCommand request, CancellationToken cancellationToken)
        {
            var list = await _service.AddHistoryrecordAsync(request.history);
            // 返回结果
            return Results<int>.DataResult(list);

        }
    }
}
